package com.lagou.code.controller;

import com.lagou.code.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jacken
 * @date 2020/4/25 6:28 PM
 */
@RestController
@RequestMapping("/code")
public class CodeController {

  @Autowired
  private CodeService codeService;

  @RequestMapping("/create/{email}")
  public Boolean createCode(@PathVariable String email) {
    return codeService.create(email);
  }

  @RequestMapping("/validate/{email}/{code}")
  public Integer validateCode(@PathVariable("email") String email, @PathVariable("code") String code) {
    return codeService.validate(email, code);
  }

}
